<?php
namespace app\redbag\controller;
use app\AdminRest;
use think\App;
use app\redbag\model\Img as Model;

class AdminImg extends AdminRest
{

    protected $model;

    public function __construct(App $app) {
        parent::__construct($app);
        $this->model         = new Model();
    }

    /**
     * User: chenniang
     * Date: 2019-12-18 14:30
     * @return void
     * descrption:列表
     */
    public function imgList(){

        $input = $this->_param;
        //uniacid
        $dis[] = ['uniacid','=',$this->_uniacid];

        if(isset($input['type'])&&$input['type']!=999){

            $dis[] = ['type','=',$input['type']];
        }
        //查询
        $data  = $this->model->imgList($dis,$input['limit']);

        return $this->success($data);
    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-09 16:49
     * @功能说明:添加图片
     */
    public function imgAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $res = $this->model->imgAdd($input);

        return $this->success($res);
    }


    /**
     * @author chenniang
     * @DataTime: 2020-04-09 16:50
     * @功能说明:编辑图片
     */
    public function imgUpdate(){

        $input = $this->_input;

        if(!empty($input)&&count($input)>1){

            $res = $this->model->imgUpdate(['id'=>$input['id']],$input);

        }else{

            $res = $this->model->imgInfo(['id'=>$input['id']]);
        }

        return $this->success($res);

    }







}
